<?php
/*
    Copyright (C) 2008 - 2010 Inanta Martsanto
    
    This file is part of Koma.

    Koma is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Koma is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Koma.  If not, see <http://www.gnu.org/licenses/>.
    
    Inanta Martsanto (inanta@inationsoft.com)
*/

define('KOMA_MYSQL', 'mysql');
define('KOMA_SQLITE', 'postgresql');
define('KOMA_POSTGRESQL', 'sqlite');

class KomaDatabaseFactory
{	
	static function getInstance($db_type = KOMA_DB_TYPE, $args = array())
	{
		$classMapper = KomaClassMapper::getInstance();

		switch($db_type)
		{
                        case KOMA_POSTGRESQL:
                                $classMapper->addClassPath(array('name' => 'KomaPostgreSQLDriver',
                                                                 'path' => 'database/drivers'));
                                return KomaPostgreSQLDriver::getInstance($args);
                                break;
                        case KOMA_SQLITE:
                                $classMapper->addClassPath(array('name' => 'KomaSQLiteDriver',
                                                                 'path' => 'database/drivers'));
				return KomaSQLiteDriver::getInstance($args);
				break;
			case KOMA_MYSQL:
			default:
                                $classMapper->addClassPath(array('name' => 'KomaMySQLDriver',
                                                                 'path' =>'database/drivers'));
				return KomaMySQLDriver::getInstance($args);
		}
	}
}
?>